package cn.itcast.service.system.impl;

import cn.itcast.dao.system.DeptDao;
import cn.itcast.domain.system.Dept;
import cn.itcast.service.system.DeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao deptDao;



    //分页查询
    @Override
    public PageInfo findAll(int page, int size,String companyId) {
        PageHelper.startPage(page,size);
        List<Dept> list = deptDao.findAll(companyId);
        return new PageInfo(list);
    }

    //查询部门
    @Override
    public List findAll(String loginCompanyId) {
        List<Dept> list = deptDao.findAll(loginCompanyId);
        return list;
    }

    //添加
    @Override
    public void save(Dept dept) {
        dept.setId(UUID.randomUUID().toString());
        deptDao.save(dept);
    }

    @Override
    public void update(Dept dept) {
        deptDao.update(dept);
    }

    @Override
    public Dept findBayId(String id) {
        Dept dept = deptDao.findBayId(id);
        return dept;
    }

    @Override
    public void delete(String id) {
        deptDao.delete(id);
    }
}
